<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    京东搜索：<input type="text" value="hdmi线">
    <script>
        /* 
           所有的标签都可以看作是Element对象
           onblur和onfocus事件
           onfocus:触发聚焦事件 点击该事件
           onblur:离开焦点事件 离开改事件
        */
        const inputObj = document.querySelector("input");

        inputObj.onfocus = function () {
            console.log("触发聚焦事件");
            if (this.value === "hdmi线") {
                this.value = '';
            }
        }

        inputObj.onblur = function () {
            console.log("离开聚焦事件");
            if (this.value === '') {
                this.value = "hdmi线";
            }
        }
    </script>
</body>

</html>